import java.util.Arrays;

public class headSort {
    public static int[] arr = new int[6];
    public static void createHead(int[] arr){
        if(arr.length==0){
            throw new RuntimeException("堆为空");
        }
      for(int child =1;child<arr.length;child++){
              shiftUp(arr,child);
      }

    }
    public static boolean isFull(){
        if(usedSize==arr.length){
            return true;
        }
        return false;
    }

    private static void  shiftUp(int[] arr, int child) {

          int parent = (child-1)/2;
          while(child>0){
              if(arr[parent]<arr[child]){
                 int tmp = arr[parent];
                 arr[parent] = arr[child];
                 arr[child] = tmp;
                 child = parent;
                  parent = (parent-1)/2;
              }else{
                  break;
              }
          }
    }
    public static int usedSize=0;
    private  static void push(int val){
        if(isFull()){
            System.out.println("满了");
        }
     arr[usedSize] = val;
    shiftUp(arr, usedSize);
        usedSize++;

    }

    public static void main(String[] args) {
         push(10);
         push(15);
         push(56);
         push(25);
         push(30);
         push(70);
        System.out.println(Arrays.toString(arr));
    }
}
